//获取切割后的二维码链接里面参数
function parseCodeParams(url, name) {
  if (!url) {
    return ''
  }
  let rawUrl = decodeURIComponent(url)
  if (rawUrl.indexOf('?') != -1) {
    let paramsString = rawUrl.split('?')[1]
    let obj = {}
    let arr = paramsString.split('&')
    for (let i = 0; i < arr.length; i++) {
      let arrNew = arr[i].split('=')
      obj[arrNew[0]] = arrNew[1]
    }
    if (name) {
      return obj[name]
    }
    return obj
  }
}

export { parseCodeParams }
